*** REPLICATION FILES Dietrich, Milner and Slapin “From Text to Political Positions on Foreign Aid: Analysis of Aid Mentions in Party Manifestos from 1960 to 2015”
*** File 2 
*** 29 May 2020
*** JBS
*** Stata SE 15.1 

*** SECOND FILE TO RUN
*** LOADS output of file 1
*** Merges in Parlgov.dta containing parlgov ideology and cabinet info, calculates gov positon variables
*** Merges in all aid data, econ data, ect...

* Merge in Parlgov data

use "input/parlgov.dta" , clear
replace electyr = 197402 if election_date=="2/28/1974" & country_id==44
replace electyr = 197410 if election_date=="10/10/1974" & country_id==44 
tempfile p

sort partyid electyr

bys cabinet_id: egen NumPartyCab = sum(cabinet_party)
bys election_id: egen SumPM = sum(prime_minister)

by election_id cabinet_id, sort: gen NumCab = _n == 1
by election_id: replace NumCab =sum(NumCab)
by election_id: replace NumCab = NumCab[_N]

save `p'

use "output/File1output.dta", clear

joinby partyid electyr using `p' , unmatch(both)

drop if _merge==2
drop _merge year

gen sdate = date(start_date, "MDY")
format sdate %td
gen syear = year(sdate)

*** FILLING IN US : USING PRESIDENT ELECTION
*** DEMOCRATS: 61320, REPUBLICANS: 61620

*** Cabinet id: Start with 1500

replace cabinet_id = 1500 if electyr==1960 & ccode==2
replace cabinet_id = 1501 if electyr==1964 & ccode==2
replace cabinet_id = 1502 if electyr==1968 & ccode==2
replace cabinet_id = 1503 if electyr==1972 & ccode==2
replace cabinet_id = 1504 if electyr==1976 & ccode==2
replace cabinet_id = 1505 if electyr==1980 & ccode==2
replace cabinet_id = 1506 if electyr==1984 & ccode==2
replace cabinet_id = 1507 if electyr==1988 & ccode==2
replace cabinet_id = 1508 if electyr==1992 & ccode==2
replace cabinet_id = 1509 if electyr==1996 & ccode==2
replace cabinet_id = 1510 if electyr==2000 & ccode==2
replace cabinet_id = 1511 if electyr==2004 & ccode==2
replace cabinet_id = 1512 if electyr==2008 & ccode==2
replace cabinet_id = 1513 if electyr==2012 & ccode==2
replace cabinet_id = 1514 if electyr==2016 & ccode==2
replace previous_cabinet_id  = cabinet_id-1 if ccode==2 & previous_cabinet_id==.
replace cabinet_party = 1 if partyid==61320 & (electyr==1960 | electyr==1964 | electyr==1976 | electyr==1992 | electyr==1996 | electyr==2008 | electyr==2012) & ccode==2
replace cabinet_party = 1 if partyid==61620 & (electyr==1968 | electyr==1972 | electyr==1980 | electyr==1984 | electyr==1988 | electyr==2000 | electyr==2004 | electyr==2016) & ccode==2
replace prime_minister = 1 if partyid==61320 & (electyr==1960 | electyr==1964 | electyr==1976 | electyr==1992 | electyr==1996 | electyr==2008 | electyr==2012) & ccode==2
replace prime_minister = 1 if partyid==61620 & (electyr==1968 | electyr==1972 | electyr==1980 | electyr==1984 | electyr==1988 | electyr==2000 | electyr==2004 | electyr==2016) & ccode==2
replace syear = electyr+1 if ccode==2


** SWEDEN, FINLAND, CANADA, US, UK, GERMANY, NORWAY, DENMARK

gen aid_party = 0

** NEED TO FILL IN NZ, AUS, IRE

** NZ 

* National Party
replace aid_party = 1 if partyid == 64620 & (cabinet_id == 701 | cabinet_id == 668 | cabinet_id ==  44 | cabinet_id == 344 | cabinet_id == 569 ///
	| cabinet_id == 285 | cabinet_id == 669 | cabinet_id == 259 ///
	| cabinet_id == 473 | cabinet_id == 514 | cabinet_id == 830 | cabinet_id == 620 | cabinet_id == 341 | cabinet_id == 388 | cabinet_id == 212 | cabinet_id == 845)
	
* Labour Party
replace aid_party = 1 if partyid == 64320 & (cabinet_id == 413 | cabinet_id == 97 | cabinet_id == 121 | cabinet_id == 611 ///
    | cabinet_id == 307 | cabinet_id == 571 | cabinet_id == 427 | cabinet_id == 251 )


*** AUS
* Liberal
replace aid_party = 1 if partyid == 63620 & (cabinet_id == 288 | cabinet_id == 786 |  cabinet_id == 261 | cabinet_id == 67 | cabinet_id == 634 ///
	| cabinet_id == 1 | cabinet_id == 795 | cabinet_id == 1024| cabinet_id == 671 | cabinet_id ==  774 ///
	| cabinet_id == 402 | cabinet_id == 423| cabinet_id == 812 | cabinet_id ==234 | cabinet_id ==1066 | cabinet_id == 1174)

* Labour
replace aid_party = 1 if partyid == 63320 & ( cabinet_id == 507 | cabinet_id == 844 | cabinet_id == 576  | cabinet_id == 401| cabinet_id ==875 | cabinet_id == 155 ///
	| cabinet_id == 725 | cabinet_id == 49 | cabinet_id == 385 | cabinet_id == 736 | cabinet_id == 108 | cabinet_id == 1061 )

	
*** Ireland

*FF
replace aid_party = 1 if partyid == 53620 & (cabinet_id == 215 | cabinet_id == 870 | cabinet_id == 748 | cabinet_id == 179 | cabinet_id == 864 | cabinet_id == 173 )

*Lab
replace aid_party = 1 if partyid == 53320 & (cabinet_id == 573 | cabinet_id == 904)

*PD
replace aid_party = 1 if partyid == 53420 & (cabinet_id == 126)
	
*** SPAIN
replace aid_party = 1 if partyid==33320 & (cabinet_id==238 | cabinet_id==834 | cabinet_id==37 | cabinet_id==654 | cabinet_id==806 | cabinet_id==497)
replace aid_party = 1 if partyid==33610 & (cabinet_id==370 | cabinet_id==309 | cabinet_id==988 | cabinet_id==1421 | cabinet_id==1494 | cabinet_id==1493)

replace aid_party = 1 if partyid==33430 & (cabinet_id==205 | cabinet_id==539 | cabinet_id==406 )

** SWEDEN
replace aid_party = 1 if partyid==11320 & (cabinet_id==424 | cabinet_id==506 | cabinet_id==821 ///
   | cabinet_id==219 | cabinet_id==577 | cabinet_id==438 | cabinet_id==647 | cabinet_id==296 ///
   | cabinet_id==478 | cabinet_id==220 | cabinet_id==732 | cabinet_id==528 | cabinet_id==156 ///
   | cabinet_id==503 | cabinet_id==641) /*SD*/
replace aid_party = 1 if partyid ==11420 & (cabinet_id==587 | cabinet_id==137 | cabinet_id==142 | cabinet_id==16) /* FP*/   
replace aid_party = 1 if partyid ==11520 & (cabinet_id==779) /*KDS */
replace aid_party = 1 if partyid == 11620 & (cabinet_id==475 | cabinet_id==854) /* Moderate  */


** GERMANY
replace aid_party = 1 if partyid==41320  & (cabinet_id==170 | cabinet_id==358 | cabinet_id==871 ///
   | cabinet_id==252 | cabinet_id==459 | cabinet_id==343 | cabinet_id==107 | cabinet_id==529 | cabinet_id==85) /*SPD*/
replace aid_party = 1 if partyid==41420 & (cabinet_id==62 | cabinet_id==31 | cabinet_id==326 ///
   | cabinet_id==472) /*FDP*/
replace aid_party = 1 if partyid==41521 & (cabinet_id==642 | cabinet_id==346 ///
   | cabinet_id==286 | cabinet_id==862 | cabinet_id==778 | cabinet_id==1071) /*CSU*/

** DENMARK
replace aid_party = 1 if partyid==13320 & (cabinet_id==841 | cabinet_id==456 | cabinet_id==660 | cabinet_id==825 ///
   | cabinet_id==320 | cabinet_id==345 | cabinet_id==50 | cabinet_id==248 | cabinet_id==379 ///
   | cabinet_id==275 | cabinet_id==740 | cabinet_id==255 | cabinet_id==189 | cabinet_id==630) /* SD*/   
replace aid_party = 1 if partyid==13420 & (cabinet_id== 596 | cabinet_id==744 | cabinet_id==824 ///
   | cabinet_id==819 | cabinet_id==195 | cabinet_id==837 | cabinet_id==57 | cabinet_id==11 ///
   | cabinet_id==316 | cabinet_id==788 | cabinet_id==71) /*V*/
replace aid_party = 1 if partyid==13620 & (cabinet_id==482 ) /*KF*/
replace aid_party = 1 if partyid==13410 & (cabinet_id==970) /*RV*/   

** NORWAY
replace aid_party = 1 if partyid==12320 & (cabinet_id==98 | cabinet_id==510 | cabinet_id==14 ///
   | cabinet_id==56 | cabinet_id==520 | cabinet_id==653 | cabinet_id==394 | cabinet_id==588 ///
   | cabinet_id==572 | cabinet_id==813 | cabinet_id==333) /*DnA*/
replace aid_party = 1 if partyid==12520 & (cabinet_id==53 | cabinet_id==181 | cabinet_id==45 ///
   | cabinet_id==300 | cabinet_id==310) /*KrF*/   
replace aid_party = 1 if partyid==12620 & (cabinet_id==284 | cabinet_id==657 | cabinet_id==485 ///
   | cabinet_id==81) /*H*/
replace aid_party = 1 if partyid==12810 & (cabinet_id==822 | cabinet_id==94) /*Sp*/
replace aid_party = 1 if partyid==12221 & (cabinet_id==693 | cabinet_id==551 ) /*SV*/


** FINLAND
replace aid_party=1 if partyid==14810 & (cabinet_id==139 | cabinet_id==203 | cabinet_id==339 ///
   | cabinet_id==391 | cabinet_id==769 | cabinet_id==143 | cabinet_id==848 | cabinet_id==466 ///
   | cabinet_id==492 | cabinet_id==776 | cabinet_id==650 | cabinet_id==877 | cabinet_id==759 ///
   | cabinet_id==277 | cabinet_id==383 ) /*KESK*/
replace aid_party = 1 if partyid==14320 & (cabinet_id== 707 | cabinet_id==115 | cabinet_id==856 ///
   | cabinet_id==618 | cabinet_id==476 | cabinet_id==614 | cabinet_id==41) /*SSDP*/
replace aid_party = 1 if partyid==14901 & (cabinet_id==764 | cabinet_id==598 | cabinet_id==378 ///
   | cabinet_id==34) /*RKP/SFP*/
replace aid_party = 1 if partyid==14520 & (cabinet_id==831) /*SKL/CD*/   
replace aid_party = 1 if partyid==14110 & (cabinet_id==206 | cabinet_id==100 | cabinet_id==352 ///
   | cabinet_id==918 | cabinet_id==1094 | cabinet_id==1110 | cabinet_id==1145) /*Green League*/
   
*** FRANCE
replace aid_party = 1 if partyid==31521 & (cabinet_id==526 | cabinet_id==692) /*MRP*/
replace aid_party = 1 if partyid==31621 & (cabinet_id==698 | cabinet_id==349 | cabinet_id==662 ///
   | cabinet_id==131 | cabinet_id==111 | cabinet_id==430 | cabinet_id==607 | cabinet_id==21 ///
   | cabinet_id==72 | cabinet_id==290 | cabinet_id==318 | cabinet_id==422 | cabinet_id==244) /*UDR/RPR*/
replace aid_party = 1 if partyid==31320 & (cabinet_id==1148 | cabinet_id==116 | cabinet_id==428 | cabinet_id==843 ///
   | cabinet_id==199 | cabinet_id==229 | cabinet_id==481) /*PR*/
replace aid_party = 1 if partyid==31626 & (cabinet_id==711 | cabinet_id==46 ///
   | cabinet_id==802 | cabinet_id==807 ) /*UMP*/   
replace aid_party = 1 if partyid==31110 & (cabinet_id== 1038 | cabinet_id==1103) /*Greens*/  
replace aid_party = 1 if partyid==31624 & (cabinet_id==820)/*UDF*/

*** CANADA
replace aid_party = 1 if partyid==62420 & (cabinet_id==619 | cabinet_id==857 | cabinet_id==415 ///
    | cabinet_id==565 | cabinet_id==696 | cabinet_id==25 | cabinet_id==783 | cabinet_id==70 ///
	| cabinet_id==785 | cabinet_id==182 | cabinet_id==55 | cabinet_id==103 | cabinet_id==308) /*LIB*/
replace aid_party = 1 if partyid==62620 & (cabinet_id==670 | cabinet_id==498 | cabinet_id==739 ///
    | cabinet_id==704 | cabinet_id==919) /*CON*/
	
	
** UK  & US 
replace aid_party = 1 if (cty=="uk" | cty=="us") & prime_minister==1   

gen aid_party_PM_diff = 0
replace aid_party_PM_diff = 1 if aid_party != prime_minister


preserve

keep partyid  electyr previous_cabinet_id syear
drop if previous_cabinet_id==.
rename syear  next_syear
rename  previous_cabinet_id cabinet_id
tempfile p1 
duplicates drop cabinet_id next_syear , force
sort   cabinet_id
save `p1'
restore
sort   cabinet_id
merge m:1   cabinet_id using `p1'
drop if _merge==2
drop _merge
gen d = next_syear-syear
sum d , 
expandcl `=r(max)+1', cl(partyid cabinet_id) gen(t)

sort partyid cabinet_id
by partyid cabinet_id : gen year = syear+_n-1
drop if year>2016 | year>next_syear

gen cabseats = cabinet_party*seats
gen pmseats = prime_minister*seats
sort cabinet_id cabinet_party year partyid

by cabinet_id cabinet_party year : egen govseats = sum(seats)
replace govseats = 0 if cabinet_party~=1
gen pty_perc = cabseats/govseats
gen pm_perc = pmseats/govseats

* Calculate mean gov aid mentions (unweighted and weighted by seatshare) and PM party mentions

foreach v of varlist aid1 proaid1 NToken NTokenFor NSent NSentFor aid_intl aid_tot proaid_tot aid_tot_sent proaid_tot_sent intl_tot rile logrile planeco markeco left_right liberty_authority state_market {
sort cabinet_id cabinet_party year 
by cabinet_id cabinet_party year : egen mean`v' = mean(`v')
gen `v'seats = `v'*pty_perc
by cabinet_id cabinet_party year : egen mean`v'seats = mean(`v'seats)

sort cabinet_id prime_minister year 
by cabinet_id prime_minister year : egen mean`v'pm = mean(`v')
replace mean`v'pm = . if prime_minister==0
gen mean`v'g = mean`v' if cabinet_party==1
gen mean`v'o = mean`v'  if cabinet_party==0

sort cabinet_id aid_party year 
by cabinet_id aid_party year : egen mean`v'devt = mean(`v')
replace mean`v'devt = . if aid_party==0

drop `v'seats mean`v'
}

collapse (mean) meanaid1seats-meanstate_marketdevt ideol rile NumPartyCab aid_party_PM_diff aid_tot proaid_tot negaid_tot, by(ccode year)
compress
sort ccode year
drop if ccode == .
drop if ccode == 2

replace aid_party_PM_diff = 1 if aid_party_PM_diff > 0  

****** Merge in Data on Aid, GDP, etc

** Merge WDI GDP data
preserve
import excel using input/wdi.xlsx, clear 
drop D
foreach v of varlist E-AA {
label var `v' "`=`v'[1]'"
replace `v' = "." if `v'==".."
}
keep A B C Q R S W X Y Z AA R S
rename A cty
rename B wbcode 
rename C year
rename Q govdebt_gdp
rename W gdp_k
rename X gdp
rename Y dgdp
rename Z gdppc_k
rename AA gdppc
drop in 1
 destring _all, replace
 ccode wbcode , from(wb) to(cow) gen(ccode)
 drop if ccode==.
 tempfile wdi 
 sort ccode year
 save `wdi'
 restore
 merge 1:1 ccode year using `wdi'
 
 drop if _merge==2
 drop _merge

merge 1:1 ccode year using input/populationWDI.dta
 drop if _merge==2
drop _merge




* Merge immigration stats

preserve
import excel using input/oecd_immig.xlsx, clear
drop in 1/4
drop C
foreach v of varlist D-K {
label var `v' "`=`v'[1]'"
replace `v' = "." if `v'==".."
}
rename D immig_in
rename E immig_out
rename F asylum_in
rename G forborn_stock
rename H for_stock
rename I acq_natl
rename J forbornlab_stock
rename K forlab_stock
drop in 1/2
rename B year
rename A cty
replace cty = cty[_n-1] if cty==""

replace cty = "South Korea" if cty=="Korea"
ccode cty, from(cty) to(cow) gen(ccode)

drop if ccode==.
destring _all, replace
compress
tempfile immig
sort ccode year
save `immig'
restore

sort ccode year
merge 1:1 ccode year using `immig'
drop if _merge==2
drop _merge


* Merge unemployment stats
preserve
import excel using  input/wdi_unemp.xlsx, clear 
rename B wbcode
rename C year
label var E  "`=E[1]'"
rename E U_ilo
label var F  "`=F[1]'"
rename F U_natl
drop in 1
drop A D
ccode wbcode , from(wb) to(cow) gen(ccode)
destring _all , replace
drop if ccode==.
tempfile u 
compress
sort ccode year
save `u'
restore
sort ccode year
merge 1:1 ccode year using `u'

drop if _merge==2
drop _merge

preserve

* Merge in data on terrorist attacks
use input/gtdallaggregate.dta , clear
ccode country_txt, from(cty) to(cow) gen(ccode)
tempfile gtd
sort ccode year
save `gtd' 
restore

sort ccode year
merge m:1 ccode year using `gtd'
drop if _merge==2
drop _merge

* Merge in Aid Data
preserve
use input/crsagg.dta , clear
ccode donorname, from(cty) to(cow) gen(ccode)
drop if ccode==.
tempfile crs
sort ccode year
save `crs' 
restore

sort ccode year
merge 1:1 ccode year using `crs'
drop if _merge==2 
drop _merge

preserve

import excel using input/oecd_dac_simone_disbursement.xlsx, clear

foreach v of varlist E-I {
replace `v' = "." if `v'==".."
}


rename A country
rename B year

rename E disburs_k_all
rename G disburs_k_bi
rename I disburs_k_mult

drop C D F H

drop in 1/8
replace country = country[_n-1] if country==""
destring _all , replace
replace country = trim(country)
ccode country , from(cty) to(cow) gen(ccode)

drop if ccode==.

tempfile dac
sort ccode year
save `dac'
restore

sort ccode year
merge 1:1 ccode year using `dac'
drop if _merge==2
drop _merge


***************
***New Aid data from OCED Commitment

preserve
import excel using input/oecd_dac_simone_commitment.xlsx, clear

foreach v of varlist E-I {
replace `v' = "." if `v'==".."
}


rename A country
rename B year

rename E commit_k_all
rename G commit_k_bi
rename I commit_k_mult

drop C D F H

drop in 1/8
replace country = country[_n-1] if country==""
destring _all , replace
replace country = trim(country)
ccode country , from(cty) to(cow) gen(ccode)

drop if ccode==.


tempfile dac_com
sort ccode year
save `dac_com'
restore

sort ccode year
merge 1:1 ccode year using `dac_com'
drop if _merge==2
drop _merge


preserve
import excel using input/oecd_dac.xlsx, clear 

foreach v of varlist F-I {
replace `v' = "." if `v'==".."
}

rename F old_disburs_all
rename G old_disburs_oda
rename H old_commit_all
rename I old_commit_oda

rename A country
rename D year
drop B  E
drop in 1/5
replace country = country[_n-1] if country==""
replace C = C[_n-1] if C==""
replace C ="_curr" if C=="Current Prices"
replace C ="_k" if C=="Constant Prices"
destring _all , replace
replace country = trim(country)
ccode country , from(cty) to(cow) gen(ccode)

drop if ccode==.

reshape wide old_disburs_all old_disburs_oda old_commit_all old_commit_oda , i(ccode year) j(C) str

label var old_disburs_all_curr "Net disbursement - Total official and private flows (current USD)"
label var old_disburs_oda_curr "Net disbursement - Official Development Assistance (current USD)"
label var old_commit_all_curr "Commitments - Total official and private flows (current USD)"
label var old_commit_oda_curr "Commitments - Official Development Assistance (current USD)"
label var old_disburs_all_k "Net disbursement - Total official and private flows (constant USD)"
label var old_disburs_oda_k "Net disbursement - Official Development Assistance (constant USD)"
label var old_commit_all_k "Commitments - Total official and private flows (constant USD)"
label var old_commit_oda_k "Commitments - Official Development Assistance (constant USD)"

tempfile dac
sort ccode year
save `dac'
restore

sort ccode year
merge 1:1 ccode year using `dac'
drop if _merge==2
drop _merge



label var meanaid1seats "Average mentions of aid1 by gov weighted by seats"
label var meanaid1pm "Average mentions of aid1 by PM party"
label var meanaid1g "Average mentions of aid1 by gov (non-weighted)"
label var meanaid1o "Average mentions of aid1 by oppos (non-weighted)"
label var meanproaid1seats "Average mentions of pro aid1 by gov weighted by seats"
label var meanproaid1pm "Average mentions of pro aid1 by PM party"
label var meanproaid1g "Average mentions of pro aid1 by gov (non-weighted)"
label var meanproaid1o "Average mentions of pro aid1 by oppos (non-weighted)"

label var meanaid_totseats  "Average aid words/all words by gov weighted by seats"
label var meanaid_totpm "Average aid words/all words by PM party"
label var meanaid_totg "Average aid words/all words by gov (non-weighted)"
label var meanaid_toto "Average aid words/all words by oppos (non-weighted)"

label var meanintl_totseats "Average intl words/all words by gov weighted by seats"
label var meanintl_totpm "Average intl words/all words by PM party"
label var meanintl_totg "Average intl words/all words by gov (non-weighted)"
label var meanintl_toto "Average intl words/all words by oppos (non-weighted)"

label var meanrileseats "Average right-left score by gov weighted by seats"
label var meanrilepm "Average right-left score of PM party"
label var meanrileg "Average right-left score of gov parties"
label var meanrileo "Average right-left score of oppos parties"

label var meanplanecoseats "Average planned economy score by gov weighted by seats"
label var meanplanecopm "Average planned economy score of PM party"
label var meanplanecog "Average planned economy score by gov (non-weighted)"
label var meanplanecoo "Average planned economy score by oppos (non-weighted)"

label var meanmarkecoseats "Average mkt economy score by gov weighted by seats"
label var meanmarkecopm "Average mkt economy score of PM party"
label var meanmarkecog "Average mkt economy score by gov (non-weighted)"
label var meanmarkecoo "Average mkt economy score by oppos (non-weighted)"

label var meanleft_rightseats "Average alt. right-left score by gov weighted by seats"
label var meanleft_rightpm "Average alt. right-left score of PM party"
label var meanleft_rightg "Average alt. right-left score by gov (non-weighted)"
label var meanleft_righto "Average alt. right-left score by oppos (non-weighted)"


label var meanproaid1devt "Average mentions of pro aid by aid ministry party"
label var meanaid1devt "Average mentions of aid by aid ministry party"
label var meanaid_intldevt "Average aid words/intl words by aid ministry party"
label var meanaid_totdevt "Average aid words/all words by aid ministry party"

preserve
import excel using input/wdi_expend.xlsx , clear
rename A country
rename C year 
replace E = "." if E==".."
replace F = "." if F==".."
rename E govexp_loc
rename F govexp_gdp
drop in 1
destring _all , replace
ccode B , from(wb) to(cow) gen(ccode)
drop B D
tempfile g
drop if ccode==.
compress
sort ccode year
save `g'
restore

sort ccode year
merge 1:1 ccode year using `g'
drop if ccode ==.
drop if _merge==2 
drop _merge

gen govexp = (govexp_gdp/100)*gdp
** Aid is in millions
*** GDP in $ amount


gen commit_gdp = (usd_commitment/(gdp/1000000))*100
gen disburs_gdp = (usd_disbursement/(gdp/1000000))*100

gen commit_pop = (usd_commitment/populationtotal2)

gen old_commit_oda_gdp_k = (old_commit_oda_k/(gdp/1000000))*100
gen old_disburs_oda_gdp_k = (old_disburs_oda_k/(gdp/1000000))*100

gen disburs_oda_k_all_gdp = (disburs_k_all/(gdp/1000000))*100
gen disburs_oda_k_bi_gdp = (disburs_k_bi/(gdp/1000000))*100
gen disburs_oda_k_mult_gdp = (disburs_k_mult/(gdp/1000000))*100

gen commit_oda_k_all_gdp = (commit_k_all/(gdp/1000000))*100
gen commit_oda_k_bi_gdp = (commit_k_bi/(gdp/1000000))*100
gen commit_oda_k_mult_gdp = (commit_k_mult/(gdp/1000000))*100

compress
sort ccode year

** Some clean-up of unemployment data and terrorist data

replace U_ilo = "." if U_ilo==".."
replace U_natl = "." if U_natl==".."

destring U_ilo U_natl, replace
replace tincident =0 if tincident==.
replace nkill=0 if nkill==.


* merge in global aid mentions and yearly global disaster data
merge m:1 year using "input/yearly disaster deaths 1980-2017.dta"
drop if _merge==2
drop _merge
drop if ccode==.

merge m:1 year using "output/globalmeanaidmentions.dta"
*drop if _merge==2
drop _merge
drop if ccode==.


save "output/File2output.dta" , replace

*******************************************************************
** Create Graph of Disbursment and Commitment post 2001 For Appendix
**

keep if year > 2001 
cor commit_gdp disburs_gdp

*** Leftwing is 0.5 sd above mean rilemeanseats
*** Rightwing is 05 sd below mean rilemeanseats

twoway (scatter disburs_gdp commit_gdp if meanrileseats <= -10.445, msymbol(T)) /// leftwing
	   (scatter disburs_gdp commit_gdp if meanrileseats > -10.445 & meanrileseats < 0.845, msymbol(Oh)) /// centrist
	   (scatter disburs_gdp commit_gdp if meanrileseats >= 0.845, msymbol(X)) /// rightwing
	   (lfit disburs_gdp commit_gdp, ///
	lpattern(dash)) || function y = x, scheme(s1mono) leg(off) ///
	ytitle("Aid Disbursements by GDP") xtitle("Aid Commitments by GDP") ///
	title("Correlation: Aid Commitments and Disbursements post 2001") ///
	text(0.7 0.1 "R = 0.91") 

	graph export "output/APPFigAidCommitDisburse.pdf", replace

	
